package com.gxa.modules.app.outpatient.onlinepay.controller;


import com.gxa.common.utils.Result;
import com.gxa.modules.app.outpatient.onlinepay.dto.PayDetail;
import com.gxa.modules.app.outpatient.onlinepay.service.OnlinePayService;
import com.gxa.modules.model.entity.fee.Patient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName PatientContorller
 * @Description
 * @Author Mr.YUAN
 * @Date 2022/11/12 11:33
 */
@RestController
@Api(tags = "在线充值接口")
@RequestMapping("/onlinepay")
public class OnlinePayContorller {
    @Autowired
    private OnlinePayService onlinePayService;

    @ApiOperation("充值")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "rechargeMoney",value = "充值金额",dataType = "double"),
            @ApiImplicitParam(paramType = "query",name = "id",value = "就诊人的id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "userId",value = "登录用户的id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "payPwd",value = "用户支付密码",dataType = "String"),
    })
    @PostMapping("/pay")
    public Result onlinePay(double rechargeMoney,Integer id,Integer userId,String payPwd) {
        Result result = onlinePayService.onlinePay(rechargeMoney, id, userId, payPwd);
        return result;
    }

    @ApiOperation("充值记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "就诊人的id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "startTime",value = "开始时间",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "endTime",value = "结束时间",dataType = "String"),
    })
    @PostMapping("/peydetail")
    public Result<PayDetail> payDetail(Integer id,String startTime,String endTime ) {
        List<PayDetail> payDetails = onlinePayService.queryDetail(id,startTime,endTime);
        return new Result().ok(payDetails);
    }


}